<template lang="">
<div class="nav-bg">
		<div id="nav">
			<router-link to="/">首页</router-link> |
			<router-link to="/result">成绩</router-link> |
			<router-link to="/about">个人</router-link>
		</div>
		<div class="nav-login" @click="toLogin(userinfo)">
			<h3 v-if="userinfo==''||userinfo==null">请登录学生系统</h3>
      <h3 v-else>{{userinfo.name}}</h3>
      <div class="login-logo">
      <img v-if="userinfo==''||userinfo==null" src="../../assets/logo.png"/>
      <img v-else src=""/>
      </div>
		</div>
	</div>
    <router-view/>
</template>

<script>
    export default{
        name:'index',
data(){
     return{
       userinfo:[],
       userimg:''
     }
  },
  created () {
      this.userinfo=JSON.parse(localStorage.getItem("token"))
      console.table(this.userinfo)
  },
  methods: {
    toLogin: function(userinfo) {
      console.log(userinfo);
      if(userinfo==null){
        this.$router.replace("/login");
      }else{
        this.$router.replace("/about");
      }
      
    }
  },
  mounted(){}
    }
</script>

<style>

</style>